#include "model/DiagramFactory.h"
#include "model/clases/DiagramaClases.h"
#include "model/der/DiagramaDer.h"
#include "utils/constantes.h"

DiagramFactory::DiagramFactory() {
}

DiagramFactory::~DiagramFactory() {
}

Diagram* DiagramFactory::getDiagram(int type, const std::string& name){

    Diagram* diagrama;

    switch(type){
    case DIAGRAMA_CLASES:
        diagrama = new DiagramaClases(name);
        break;
    case DIAGRAMA_DER:
        diagrama = new DiagramaDer(name);
        break;
    default:
        diagrama = new DiagramaDer(name);
        break;
    }

    return diagrama;
}

Diagram* DiagramFactory::getDiagramFromXML(XmlReader& reader){

    if (reader.getRoot()) {
    	reader.setCurrentNode(reader.getRoot());
    	std::string type = reader.getCurrentNodeProperty(TARGET_TYPE);
    	Utils utils;
    	if ( utils.convertToInt(type) == DIAGRAMA_CLASES ) {
    		return new DiagramaClases();
    	}
    	else {
    		return new DiagramaDer();
    	}
    }
    return new DiagramaDer();
}
